package com.yigang.controller;

import java.text.ParseException;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yigang.entity.Parameter;
import com.yigang.service.ParameterService;
import com.yigang.utils.ResultUtil;
/**
 * @author 陈佳祥
 *产品参数管理
 */
@Controller
@RequestMapping("/parameter")
public class ParameterController {
		@Autowired
	private ParameterService parameterService;
		//椤甸潰閲嶅畾鍚�
		@RequestMapping("parameterList")
		public String parameterList() {
			return "jsp/parameter/parameterList";
		}
		@RequestMapping("addParameter")
		public String addParameter() {
			return "jsp/parameter/addParameter";
		}
		
		@RequestMapping("editParameter/{parameter_id}")
		public String editParameter(@PathVariable("parameter_id") int parameter_id, HttpSession session) {
			Parameter parameter = parameterService.selectParameterById(parameter_id);
		
			session.setAttribute("parameter", parameter);
			return "jsp/parameter/editParameter";
		}
		
		//澧炲垹鏌ユ敼鏂规硶
		@RequestMapping("insertParameter")
		@ResponseBody
		public ResultUtil insertParameter(Parameter record) {
			parameterService.insertSelective(record);
			return ResultUtil.ok();

		}

		@RequestMapping("deleteParameterById")
		@ResponseBody
		public ResultUtil deleteParameterById(int parameter_id) {
			
			return parameterService.deleteByPrimaryKey(parameter_id);
		}

		@RequestMapping("getParameterList")
		@ResponseBody
		public ResultUtil getParameterList(Integer page, Integer limit, Parameter record) {

			return parameterService.selectParameterList(page, limit, record);
		}

		@RequestMapping("updateParameter")
		@ResponseBody
		public ResultUtil updateProduct(Parameter record) throws ParseException {
			
			return parameterService.updateByPrimaryKeySelective(record);
		}

}
